package b.k.a;

import android.graphics.Rect;
import b.k.a.a.a;
import java.util.Comparator;

/* compiled from: FocusStrategy */
public class d<T> implements Comparator<T> {
    public final Rect a = new Rect();
    public final Rect b = new Rect();
    public final boolean c;
    public final b<T> d;

    public d(boolean z, b<T> bVar) {
        this.c = z;
        this.d = bVar;
    }

    public int compare(T t, T t2) {
        Rect rect = this.a;
        Rect rect2 = this.b;
        ((a) this.d).a(t, rect);
        ((a) this.d).a(t2, rect2);
        int i = rect.top;
        int i2 = rect2.top;
        int i3 = -1;
        if (i < i2) {
            return -1;
        }
        if (i > i2) {
            return 1;
        }
        i = rect.left;
        i2 = rect2.left;
        if (i < i2) {
            if (this.c) {
                i3 = 1;
            }
            return i3;
        } else if (i > i2) {
            if (!this.c) {
                i3 = 1;
            }
            return i3;
        } else {
            i = rect.bottom;
            i2 = rect2.bottom;
            if (i < i2) {
                return -1;
            }
            if (i > i2) {
                return 1;
            }
            i = rect.right;
            i2 = rect2.right;
            if (i < i2) {
                if (this.c) {
                    i3 = 1;
                }
                return i3;
            } else if (i <= i2) {
                return 0;
            } else {
                if (!this.c) {
                    i3 = 1;
                }
                return i3;
            }
        }
    }
}
